package com.jilefojing.beans.pojos.enhanced;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.List;

import com.jilefojing.beans.enums.ItemTypeEnumForSource;
import com.jilefojing.beans.enums.forcomment.StatusEnumForComment;
import com.jilefojing.beans.pojos.Comment;
import com.jilefojing.beans.pojos.enhanced.base.BaseEnhanced;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年07月21日 15时40分56秒
 */
public class EnhancedComment extends BaseEnhanced {
	public EnhancedComment(Comment comment) {
		// TODO 自动生成 细微误差自己调整
		if (comment.getId() != null) {
			this.id = comment.getId();
		}
		if (comment.getItemType() != null) {
			this.itemType = ItemTypeEnumForSource.getItemTypeEnumByCode(comment.getItemType());
		}

		if (comment.getItemId() != null && this.itemType != null) {
			try {
				Class<? extends BaseEnhanced> _EnhancedClass = this.itemType.getEnhancedItemClass();
				BaseEnhanced _EnhancedItem = _EnhancedClass.newInstance();
				for (Method _Method : _EnhancedClass.getDeclaredMethods()) {
					if (_Method.getName().equals("setId")) {
						_Method.invoke(_EnhancedItem, comment.getItemId());
						break;
					}
				}
				this.enhancedItem = _EnhancedItem;
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}

		if (comment.getTopItemType() != null) {
			this.topItemType = ItemTypeEnumForSource.getItemTypeEnumByCode(comment.getTopItemType());
		}

		if (comment.getTopItemId() != null && this.topItemType != null) {
			try {
				Class<? extends BaseEnhanced> _EnhancedClass = this.topItemType.getEnhancedItemClass();
				BaseEnhanced _EnhancedItem = _EnhancedClass.newInstance();
				for (Method _Method : _EnhancedClass.getDeclaredMethods()) {
					if (_Method.getName().equals("setId")) {
						_Method.invoke(_EnhancedItem, comment.getTopItemId());
						break;
					}
				}
				this.enhancedTopItem = _EnhancedItem;
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}

		if (comment.getUserId() != null) {
			EnhancedUser enhancedUser = new EnhancedUser();
			enhancedUser.setId(comment.getUserId());
			this.enhancedUser = enhancedUser;
		}
		this.content = comment.getContent();
		if (comment.getStatus() != null) {
			this.status = StatusEnumForComment.getStatusEnumByCode(comment.getStatus());
		}
		this.createTime = comment.getCreateTime();
		this.updateTime = comment.getUpdateTime();
		if (comment.getTopCommentId() != null) {
			EnhancedComment _EnhancedTopComment = new EnhancedComment();
			_EnhancedTopComment.setId(comment.getTopCommentId());
			this.enhancedTopComment = _EnhancedTopComment;
		}
	}

	public EnhancedComment() {
	}

	private long id;
	private ItemTypeEnumForSource itemType;
	private BaseEnhanced enhancedItem;
	private EnhancedUser enhancedUser;
	private String content;
	private StatusEnumForComment status;
	private Date createTime;
	private Date updateTime;
	private EnhancedStatistics enhancedStatistics;
	private ItemTypeEnumForSource topItemType;
	private BaseEnhanced enhancedTopItem;
	private EnhancedComment enhancedTopComment;
	private EnhancedAttitude enhancedAttitude;// 用户态度

	/**
	 * 顶部评论的下面的关联评论列表
	 */
	private List<EnhancedComment> enhancedChildCommentsForTop;
	/**
	 * 顶部评论的下面的关联评论列表总数
	 */
	private int countChildCommentForTop;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public ItemTypeEnumForSource getItemType() {
		return itemType;
	}

	public void setItemType(ItemTypeEnumForSource itemType) {
		this.itemType = itemType;
	}

	public BaseEnhanced getEnhancedItem() {
		return enhancedItem;
	}

	public void setEnhancedItem(BaseEnhanced enhancedItem) {
		this.enhancedItem = enhancedItem;
	}

	public EnhancedUser getEnhancedUser() {
		return enhancedUser;
	}

	public void setEnhancedUser(EnhancedUser enhancedUser) {
		this.enhancedUser = enhancedUser;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public StatusEnumForComment getStatus() {
		return status;
	}

	public void setStatus(StatusEnumForComment status) {
		this.status = status;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public EnhancedStatistics getEnhancedStatistics() {
		return enhancedStatistics;
	}

	public void setEnhancedStatistics(EnhancedStatistics enhancedStatistics) {
		this.enhancedStatistics = enhancedStatistics;
	}

	public ItemTypeEnumForSource getTopItemType() {
		return topItemType;
	}

	public void setTopItemType(ItemTypeEnumForSource topItemType) {
		this.topItemType = topItemType;
	}

	public BaseEnhanced getEnhancedTopItem() {
		return enhancedTopItem;
	}

	public void setEnhancedTopItem(BaseEnhanced enhancedTopItem) {
		this.enhancedTopItem = enhancedTopItem;
	}

	public List<EnhancedComment> getEnhancedChildCommentsForTop() {
		return enhancedChildCommentsForTop;
	}

	public void setEnhancedChildCommentsForTop(List<EnhancedComment> enhancedChildCommentsForTop) {
		this.enhancedChildCommentsForTop = enhancedChildCommentsForTop;
	}

	public int getCountChildCommentForTop() {
		return countChildCommentForTop;
	}

	public void setCountChildCommentForTop(int countChildCommentForTop) {
		this.countChildCommentForTop = countChildCommentForTop;
	}

	public EnhancedComment getEnhancedTopComment() {
		return enhancedTopComment;
	}

	public void setEnhancedTopComment(EnhancedComment enhancedTopComment) {
		this.enhancedTopComment = enhancedTopComment;
	}

	public EnhancedAttitude getEnhancedAttitude() {
		return enhancedAttitude;
	}

	public void setEnhancedAttitude(EnhancedAttitude enhancedAttitude) {
		this.enhancedAttitude = enhancedAttitude;
	}

}